package com.example.websocket.controller;

import com.example.websocket.pojo.LoginDTO;
import com.example.websocket.pojo.Result;
import com.example.websocket.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpSession;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @ author 韩
 * time: 2024/2/16 18:06
 */
@RestController
@RequestMapping("/user")
@Tag(name = "UserController",description = "用户相关的功能实现")
public class UserController {

    @Autowired
    private UserService userService;

    @Operation(summary = "登录接口 没有进行加盐处理")
    @PostMapping("/login")
    public Result login(@RequestBody LoginDTO dto, HttpSession session) {
        return userService.login(dto,session);
    }

    @Operation(summary = "注册接口")
    @PostMapping("/register")
    public Result register(@RequestBody LoginDTO dto) {
        return userService.register(dto);
    }

    @Operation(summary = "获取所以用户列表，现已废弃不用 早先的版本没有加好友的功能和消息列表的概念 就直接展示所有人")
    @GetMapping("/getUserList")
    public Result getUserList(){
        List<String> userList = userService.getUserList();
        return Result.ok(userList);
    }
}
